﻿<?php
	header("Content-Type:text/html;charset=UTF-8");
	require_once 'config.php';
?>	
<html>
<head>
<title>查看单笔退款详情</title>
<link href="css/refund.css" rel="stylesheet" type="text/css" />

</head>
<body>
<b>此DEMO的功能:查看单笔退款详情</b>
  <?php include 'header.php'?>
  <?php
	/* Build By fhalipay */

/* 单笔退款详情 Start*/
	
	//参数数组
	$paramArr = array(

		/* API系统级输入参数 Start */

	    	'method' => 'taobao.refund.get',  //API名称
		   'session' => $sessions, //session
	     'timestamp' => date('Y-m-d H:i:s'),			
		    'format' => 'xml',  //返回格式,本demo仅支持xml
    	   'app_key' => $appKey,  //Appkey			
	    		 'v' => '2.0',   //API版本号		   
		'sign_method'=> 'md5', //签名方式			

		/* API系统级参数 End */				 

		/* API应用级输入参数 Start*/

	    	'fields' => 'refund_id,alipay_no,tid,oid,buyer_nick,seller_nick,total_fee,status,created,refund_fee,good_status,has_good_return,payment,reason,desc,iid,title,price,num,good_return_time,company_name,sid,address,shipping_type,refund_remind_timeout',  //返回字段
         'refund_id' => $refund_id,  //退款单号
			  
		/* API应用级输入参数 End*/
	);


	//生成签名
	$sign = createSign($paramArr,$appSecret);
	
	//组织参数
	$strParam = createStrParam($paramArr);
	$strParam .= 'sign='.$sign;
	
	//构造Url
	$urls = $url.$strParam;

	$results = vita_get_url_content($urls);

	//解析Xml数据
	$results = getXmlData($results);
	
	//获取返回信息
	$refund = $results['refund'];
	
/* 单笔退款详情 End*/	


?>
  
  
  <?php 
	if(empty($results)){
	//返回错误信息
		echo '不存在的退款编号';
	}else{
	?>
<table width="80%" border="0" align="center">
  <tr>
    <td colspan="4" bgcolor="#FFFFCC">退款编号：<?php echo $refund['refund_id']?></td>
  </tr>  
  <tr>
    <td colspan="4" bgcolor="#66FFCC">退款状态：<?php echo getStatus($refund['status'])?></td>
  </tr>
  <tr>
    <td colspan="4" bgcolor="#CCCCCC">申请退款的宝贝</td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#CCFFCC" width="50%">宝贝名称</td>
    <td colspan="2" bgcolor="#CCFFCC"><?php echo $refund['title']?></td>
  </tr>
  
  <tr>
    <td colspan="2" bgcolor="#CCFFCC">宝贝价格</td>
    <td colspan="2" bgcolor="#CCFFCC"><?php echo $refund['price']?></td>
  </tr>

  <tr>
    <td colspan="2" bgcolor="#CCFFCC">购买数量</td>
    <td colspan="2" bgcolor="#CCFFCC"><?php echo $refund['num']?></td>
  </tr>    
  
  <tr>
    <td colspan="2" bgcolor="#CCCCCC">退款协议信息：</td>
    <td colspan="2" bgcolor="#CCCCCC">订单详情：</td>
  </tr> 
  <tr>
    <td bgcolor="#CCFFCC">申请退款时间：</TH>
    <td bgcolor="#CCFFCC"> <?php echo $refund['created']?></TH>
    <td bgcolor="#CCFFCC">订单编号：</td>
    <td bgcolor="#CCFFCC"><?php echo $refund['tid']?></td>
  </tr>
  <tr>
    <td bgcolor="#CCFFCC">退款状态：</TH>
    <td bgcolor="#CCFFCC"> </TH>
      <?php echo getStatus($refund['status'])?>
    <td bgcolor="#CCFFCC">支付宝交易号：</td>
    <td bgcolor="#CCFFCC"><?php echo $refund['alipay_no']?></td>
  </tr>
  <tr>
    <td bgcolor="#CCFFCC">货物状态：</TH>
    <td bgcolor="#CCFFCC"> </TH>
      <?php echo getGood_status($refund['good_status'])?>
    <td bgcolor="#CCFFCC">&nbsp;</td>
    <td bgcolor="#CCFFCC">&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="#CCFFCC">买家是否需要退货：</TH>
    <td bgcolor="#CCFFCC">&nbsp;</TH><?php echo getReturn($refund['has_good_return'])?>
    <td bgcolor="#CCFFCC">订单状态：</td>
    <td bgcolor="#CCFFCC"><?php echo getOrder_Status($refund['order_status']).$refund['order_status']?></td>
  </tr>
  <tr>
    <td bgcolor="#CCFFCC"><STRONG>退还给买家的金额：</STRONG></TH>
    <td bgcolor="#CCFFCC"></TH>
      <?php echo $refund['refund_fee']?>
    <td bgcolor="#CCFFCC">买　　家：</td>
    <td bgcolor="#CCFFCC"><?php echo $refund['buyer_nick']?></td>
  </tr>
  <tr>
    <td bgcolor="#CCFFCC"><STRONG>支付给卖家的金额：</STRONG></TH>
    <td bgcolor="#CCFFCC"></TH>
      <?php echo $refund['payment']?>
    <td bgcolor="#CCFFCC">商品总价：</td>
    <td bgcolor="#CCFFCC"><?php echo $refund['price']*$refund['num']?> 元</td>
  </tr>
  <tr>
    <td bgcolor="#CCFFCC">退款原因：</TH>
    <td bgcolor="#CCFFCC">&nbsp;</TH><?php echo $refund['reason']?>
    <td bgcolor="#CCFFCC">&nbsp;</td>
    <td bgcolor="#CCFFCC">&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="#CCFFCC">退款说明：</TH>
    <td bgcolor="#CCFFCC">&nbsp;</TH><?php echo $refund['desc']?>
    <td bgcolor="#CCFFCC">&nbsp;</td>
    <td bgcolor="#CCFFCC">&nbsp;</td>
  </tr>     
</table>
<br>
<p align="center">API返回信息</p>
<table border="0" width="80%" bgcolor="#dddddd" align="center">
  <tr>
    <td>退款单号 </td>
    <td><?php echo $refund['refund_id']?> </td>
  </tr>
  <tr>
    <td>淘宝交易单号 </td>
    <td><?php echo $refund['tid']?> </td>
  </tr>
  <tr>
    <td>子订单号。如果是单笔交易oid会等于tid </td>
    <td><?php echo $refund['oid']?> </td>
  </tr>
  <tr>
    <td>支付宝交易号 </td>
    <td><?php echo $refund['alipay_no']?> </td>
  </tr>
  <tr>
    <td>交易总金额。精确到2位小数;单位:元。如:200.07，表示:200元7分 </td>
    <td><?php echo $refund['total_fee']?> </td>
  </tr>
  <tr>
    <td>买家昵称 </td>
    <td><?php echo $refund['buyer_nick']?> </td>
  </tr>
  <tr>
    <td>卖家昵称 </td>
    <td><?php echo $refund['seller_nick']?> </td>
  </tr>
  <tr>
    <td>退款申请时间。格式:yyyy-MM-dd HH:mm:ss </td>
    <td><?php echo $refund['created']?> </td>
  </tr>
  <tr>
    <td>更新时间。格式:yyyy-MM-dd HH:mm:ss </td>
    <td><?php echo $refund['modified']?> </td>
  </tr>
  <tr>
    <td>退款对应的订单交易状态</td>
    <td><?php echo getOrder_Status($refund['order_status']).$refund['order_status']?>  </td>
  </tr>
  <tr>
    <td>退款状态</td>
    <td><?php echo getStatus($refund['status'])?> </td>
  </tr>
  <tr>
    <td>货物状态</td>
    <td><?php echo getGood_status($refund['good_status'])?> </td>
  </tr>
  <tr>
    <td>买家是否需要退货。可选值:true(是),false(否) </td>
    <td><?php echo $refund['has_good_return']?> </td>
  </tr>
  <tr>
    <td>退还金额(退还给买家的金额)。精确到2位小数;单位:元。如:200.07，表示:200元7分 </td>
    <td><?php echo $refund['refund_fee']?>  </td>
  </tr>
  <tr>
    <td>支付给卖家的金额(交易总金额-退还给买家的金额)。精确到2位小数;单位:元。如:200.07，表示:200元7分 </td>
    <td><?php echo $refund['payment']?>  </td>
  </tr>
  <tr>
    <td>退款原因 </td>
    <td><?php echo $refund['reason']?> </td>
  </tr>
  <tr>
    <td>退款说明 </td>
    <td><?php echo $refund['desc']?> </td>
  </tr>
  <tr>
    <td>申请退款的商品字符串编号 </td>
    <td><?php echo $refund['iid']?> </td>
  </tr>
  <tr>
    <td>商品标题 </td>
    <td><?php echo $refund['title']?> </td>
  </tr>
  <tr>
    <td>商品价格。精确到2位小数;单位:元。如:200.07，表示:200元7分 </td>
    <td><?php echo $refund['price']?> </td>
  </tr>
  <tr>
    <td>商品购买数量 </td>
    <td><?php echo $refund['num']?>  </td>
  </tr>
  <tr>
    <td>退货时间。格式:yyyy-MM-dd HH:mm:ss </td>
    <td><?php echo $refund['good_return_time']?> </td>
  </tr>
  <tr>
    <td>物流公司名称 </td>
    <td><?php echo $refund['company_name']?> </td>
  </tr>
  <tr>
    <td>退货运单号 </td>
    <td><?php echo $refund['sid']?> </td>
  </tr>
  <tr>
    <td>卖家收货地址 </td>
    <td><?php echo $refund['address']?>  </td>
  </tr>
  <tr>
    <td>物流方式 </td>
    <td><?php echo $refund['shipping_type']?> </td>
  </tr>
  <tr>
    <td>退款超时结构</td>
    <td><?php echo $refund['refund_remind_timeout']?> </td>
  </tr>
</table>
    
    <?php
	}
	?>


</body>
</html>
